﻿using Nancy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sys.API.DTO;
using System.Text;
using Nancy.ModelBinding;
using Nancy.Security;



namespace Sys.API.Models
{
    public class HomeModule : BaseModule
    {
         

        //[SetterProperty]
        //IOAuthService ouath = new OAuthService();
        //public IOAuthService OAuth{ get; set; }
        //注意：这里是构造函数
        public HomeModule() ://ITokenizer tokenizer
            base("/OAuth")
        {
            Get["/"] = paramaters =>
          {
              return "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/><title>接口API</title></head><body> <h1>接口API[2015-07-28]</h1></body></html> ";
          };
            Get["/Service.do"] = _ =>
            {
                try
                {
                    List<DTOProject> rlist = new List<DTOProject>();
                    return Response.AsJson(CreateWebApiMsg(1, "", rlist));
                }
                catch
                {
                    return Response.AsJson(CreateWebApiMsg(-1, "", ""));
                }
            };

            Get["/GetToken.do"] = _ =>
            {
                var appid = (string)this.Request.Form.AppId;
                var secret = (string)this.Request.Form.AppSecret;

                return Response.AsJson(CreateWebApiMsg(-1, "请求Token：请求有误"));
            };

            Get["/RefreshToken.do"] = _ =>
            {
                return Response.AsJson(CreateWebApiMsg(-1, "刷新token：请求有误"));
            };

           
        }

       
    }
}